<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/20
 * Time: 10:23
 */
class 列出目录中的所有子目录
{

}

function listdir($dir){
    if ($handle = opendir($dir)){
        $output = array();
        while (false !== ($item = readdir($handle))){
            if (is_dir($dir.'/'.$item) and $item != "." and $item != ".."){
                $output[] = $dir.'/'.$item;
                $output = array_merge($output, ListDescendantDirectories($dir.'/'.$item));
            }
        }
        closedir($handle);
        return $output;
    }else{
        return false;
    }
}

$dirs = listdir('myDirectory');
foreach($dirs as $dir){
    echo $dir.'<br>';
}